package com.smartticket.jeju.repository;

import java.sql.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import com.smartticket.jeju.model.Purchase;

public class PurchaseRepositoryImpl implements PurchaseRepository 
{
	@Autowired
	private JdbcDaoSupport jdbcDaoSupport;
	
	@Autowired
	@Qualifier("purchaseRowMapper")
	private RowMapper<Purchase> rowMapper;

	public void insert(String user_id, int ticket_id, int count, Date date) 
	{
		String query = "insert into purchase values(?, ?, ?, ?, ?)";
		jdbcDaoSupport.getJdbcTemplate().update(query, 155, user_id, ticket_id, count, date);

	}

	public List<Purchase> findAllById(String user_id) 
	{
		String query = "select * from purchase where user_id = ?";
		
		return jdbcDaoSupport.getJdbcTemplate().query(query, rowMapper, user_id);
	}

	public void insert(Purchase purchase) {
		// TODO Auto-generated method stub
		
	}

}
